﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StudentSign.aspx.cs" Inherits="ZX.WebApp.Crm.StudentSign" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script type="text/javascript" src="../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <script src="../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../Scripts/Public.js" type="text/javascript"></script>
    <link href="../Styles/base.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/extendTable.css" rel="stylesheet" type="text/css" />
</head>
<body class="yui-skin-sam">
    <form id="form1" runat="server">
    <div>
        <div id="content">
                <h3>
                    查询</h3>
                <table class="table1" id="table1">
                    <tr>
                        <th class="width10"><span>企业名称</span></th>
                        <td class="width20">
                            <input type="text" id="CustomerName" name="CustomerName" class="width60" />
                        </td>
                        <th class="width10"><span>学员姓名</span></th>
                        <td class="width20">
                            <input type="text" id="ClassName" name="ClassName" class="width60" />
                        </td>
                        <th class="width10"><span>团号</span></th>
                        <td class="width20">
                            <input type="text" id="GroupName" name="GroupName" class="width60" />
                        </td>
                        
                    </tr>
                    <tr>
                        <th><span>业绩归属</span></th>
                        <td>
                            <select id="DeptName" name="DeptName" class="width65"></select>
                        </td>    
                        <th><span>客户经理</span></th>
                        <td>
                            <select id="CustomerMgrName" name="CustomerMgrName" class="width65"></select>
                        </td>
                        <th><span>是否决策人</span></th>
                        <td>
                            <select id="IsDecision" name="IsDecision" class="width65">
                                <option value=""></option>
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th><span>是否复训</span></th>
                        <td>
                            <select id="IsTrain" name="IsTrain" class="width65">
                                <option value=""></option>
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                        </td>
                        <th><span>是否签到</span></th>
                        <td>
                            <select id="IsSignIn" name="IsSignIn" class="width65">
                                <option value=""></option>
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                        </td>
                        <td colspan="2"></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td colspan="5">
                            <input type="button" id="btnCheck" name="btnCheck" onclick="return QueryData();"
                                value="查询" class="btnCheck" style="width:50px; height:25px;" />
                        </td>
                    </tr>
                </table>
        </div>
        <div class="extendDiv">
            <h3><div style="width:700px;">学员列表|
                            总人数:<label id="TotalCount" style="color:Red;">0</label>人&nbsp;
                            已分团:<label id="IsGroupCount" style="color:Red;">0</label>人&nbsp;
                            未分团:<label id="UnGroupCount" style="color:Red;">0</label>人&nbsp;
                            复训:<label id="IsTrainCount" style="color:Red;">0</label>人&nbsp;
                            已签到:<label id="IsSignInCount" style="color:Red;">0</label>人&nbsp;
                            未签到:<label id="IsUnSignInCount" style="color:Red;">0</label>人&nbsp;
                            企业:<label id="IsCustomerNameCount" style="color:Red;">0</label>家&nbsp;
                            <input type="button" id="btnResource" name="btnResource" onclick="return fnResource();"
                                value="资源分配" class="btnCheck" style="width:60px; height:25px;" />
                            <input type="button" id="btnCancelResource" name="btnResource" onclick="return fnCancelResource();"
                                value="取消资源分配" class="btnCheck" style="width:80px; height:25px;" />
                            </div></h3>
            <div id="cellediting"></div>
        </div>
        <div id="dialog1" class="yui-pe-content">
            <div class="hd">
                信息选择</div>
            <div class="bd">
                <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                    margin: 0px; padding: 0px;"></iframe>
            </div>
        </div>
    </div>
    </form>
</body>
<script type="text/javascript">
    var myDataSource, myDataTable;
    var Id = "", const_Height = "", uId = "";
    YAHOO.namespace("example.container");
    YAHOO.util.Event.onDOMReady(function () {
        var handleSubmit = function () {
            var editwindow = document.getElementById("EditUIWindow1");
            if (editwindow) {
                uId = editwindow.contentWindow.ids;
                if (uId != "") {
                    SaveResource(0);
                }
            }
            YAHOO.example.container.dialog1.hide();
        };
        var handleCancel = function () {
            this.cancel();
        };
        var handleSuccess = function (o) {
            var response = o.responseText;
            response = response.split("<!")[0];
            document.getElementById("resp").innerHTML = response;
        };
        var handleFailure = function (o) {
            alert("Submission failed: " + o.status);
        };
        YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
					            { width: "650px",
					                height: "400px",
					                fixedcenter: true,
					                visible: false,
					                draggable: true,
					                close: true,
					                modal: true,
					                autofillheight: "body",
					                constraintoviewport: true,
					                buttons: [{ text: "确定", handler: handleSubmit, isDefault: true },
								            { text: "取消", handler: handleCancel}]
					            });
        YAHOO.example.container.dialog1.callback = { success: handleSuccess, failure: handleFailure };
        YAHOO.example.container.dialog1.render();
        //拖动大小dialog1
        var resize1 = new YAHOO.util.Resize("dialog1", {
            handles: ["br"],
            autoRatio: false,
            minWidth: 450,
            minHeight: 300,
            status: false
        });
        resize1.on("startResize", function (args) {
            if (this.cfg.getProperty("constraintoviewport")) {
                var D = YAHOO.util.Dom;
                var clientRegion = D.getClientRegion();
                var elRegion = D.getRegion(this.element);
                resize1.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
                resize1.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
            } else {
                resize1.set("maxWidth", null);
                resize1.set("maxHeight", null);
            }

        }, YAHOO.example.container.dialog1, true);
        resize1.on("resize", function (args) {
            var panelHeight = args.height;
            this.cfg.setProperty("height", panelHeight + "px");
        }, YAHOO.example.container.dialog1, true);
    });
    YAHOO.util.Event.addListener(window, "load", function () {
        Id = getPar1("id");
        const_Height = ($(document).height() - ($("#table1").height() + 130)) + "px";
        LoadDeptListData();
        LoadCustomerMgrName();
        BindData();
    });
    var BindData = function () {
        YAHOO.example.InlineCellEditing = function () {
            var myColumnDefs = [
                { key: 'MajorStudentId', label: 'MajorStudentId', width: 100, sortable: true },
                { key: 'iSun_Selected', label: '', width: 10, formatter: "checkbox" },
		        { key: 'GroupName', label: '团号', width: 40, sortable: true, resizeable: true,
		            editor: new YAHOO.widget.TextboxCellEditor({ validator: YAHOO.widget.DataTable.validateNumber })
		        },
                { key: 'GroupNumber', label: '序号', width: 40, sortable: true, resizeable: true,
                    editor: new YAHOO.widget.TextboxCellEditor({ validator: YAHOO.widget.DataTable.validateNumber })
                },
                { key: 'ClassName', label: '学员姓名', width: 60, sortable: true, resizeable: true },
                { key: 'PrintClassName', label: '打印姓名', width: 60, sortable: true, resizeable: true },
                { key: 'Exp4', label: '学员手机号', width: 80, sortable: true, resizeable: true },
                { key: 'Sex', label: '性别', width: 25, sortable: true, resizeable: true },
                { key: 'Post', label: '职位', width: 110, sortable: true, resizeable: true },
		        { key: 'IsDecision', label: '决策人', width: 35, sortable: true, resizeable: true, formatter: formatDecision },
                { key: 'IsTrain', label: '复训', width: 30, sortable: true, resizeable: true, formatter: formatTrain },
		        { key: 'AssistanceName', label: '辅导员', width: 60, sortable: true, resizeable: true },
		        { key: 'OrderofDeptName', label: '所属分公司', width: 120, sortable: true, resizeable: true },
		        { key: 'CustomerMgrName', label: '客户经理', width: 60, sortable: true, resizeable: true },
                { key: 'NegotiateTeachName', label: '谈单老师', width: 60, sortable: true, resizeable: true },
		        { key: 'CustomerName', label: '客户名称', width: 250, sortable: true, resizeable: true },
		        { key: 'ColonelName', label: '团长', width: 60, sortable: true, resizeable: true },
                { key: 'IDCard', label: '身份证', width: 130, sortable: true, resizeable: true },
                { key: 'ArriveatTime', label: '到达日期', width: 80, sortable: true, resizeable: true },
                { key: 'HourseTypeName', label: '房型', width: 50, sortable: true, resizeable: true },
                { key: 'ActualHourseTypeName', label: '实际房型', width: 50, sortable: true, resizeable: true },
                { key: 'TrafficTypeName', label: '交通方式', width: 50, sortable: true, resizeable: true },
                { key: 'IsSignIn', label: '是否签到', width: 50, sortable: true, resizeable: true, formatter: formatIsSignIn },
                { key: 'SignIn', label: '签到时间', width: 110, sortable: true, resizeable: true, formatter: formatSignIn }
            ];
            myDataSource = new YAHOO.util.DataSource([{ "Expr1": "", "iSun_Selected": "", "ID": "", "OrderProductID": "", "CustomerId": "",
                "MajorStudentId": "", "Code": "", "CustomerCode": "", "ClassName": "", "PrintClassName": "", "Exp4": "", "Sex": "", "Post": "", "IDCard": "",
                "GroupName": "", "GroupNumber": "", "ColonelName": "", "AssistanceName": "", "CustomerName": "", "CustomerMgrName": "",
                "NegotiateTeachName": "", "OrderofDeptName": "", "IsDecision": "", "IsTrain": "", "ArriveatTime": "",
                "HourseTypeName": "", "ActualHourseTypeName": "", "TrafficTypeName": "", "IsSignIn": "", "SignIn": ""
            }]);
            myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
            myDataSource.responseSchema = {
                fields: ['Expr1', 'iSun_Selected', 'ID', 'OrderProductID', 'CustomerId', 'MajorStudentId', 'Code',
                    'CustomerCode', 'ClassName', 'PrintClassName', 'Exp4', 'Sex', 'Post', 'IDCard', 'GroupName',
                    'GroupNumber', 'ColonelName', 'AssistanceName', 'CustomerName', 'CustomerMgrName',
                    'NegotiateTeachName', 'OrderofDeptName', 'IsDecision', 'IsTrain', 'ArriveatTime',
                    'HourseTypeName', 'ActualHourseTypeName', 'TrafficTypeName', 'IsSignIn', 'SignIn']
            };
            myDataTable = new YAHOO.widget.ScrollingDataTable("cellediting", myColumnDefs, myDataSource,
                        { width: "99.8%", height: const_Height, selectionMode: "single" });

            var onEventSaveCellEditor = function (oArgs) {
                SaveValue(oArgs.editor._oColumn.key, oArgs.newData, oArgs.oldData);
            }
            myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow);
            myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);
            myDataTable.subscribe("rowClickEvent", myDataTable.onEventSelectRow);
            myDataTable.subscribe("rowDblclickEvent", onRowDoubleSetColonel);
            myDataTable.subscribe("cellClickEvent", myDataTable.onEventShowCellEditor);
            myDataTable.subscribe("editorSaveEvent", onEventSaveCellEditor);
            myDataTable.subscribe("checkboxClickEvent", function (oArgs) {
                var elCheckbox = oArgs.target;
                var oRecord = this.getRecord(elCheckbox);
                oRecord.setData("iSun_Selected", elCheckbox.checked);
            });
            myDataTable.hideColumn(parseInt(0)); myDataTable.refreshView();
            LoadStudentData();
            return {
                oDS: myDataSource,
                oDT: myDataTable
            };
        } ();
    }
    //格式化列
    var formatDecision = function (elCell, oRecord, oColumn, sData) {
        if (sData == "0") {
            elCell.innerHTML = "否";
        } else if (sData == "1") {
            elCell.innerHTML = "是";
        } else {
            elCell.innerHTML = "";
        }
    }
    var formatTrain = function (elCell, oRecord, oColumn, sData) {
        if (sData == "0") {
            elCell.innerHTML = "否";
        } else if (sData == "1") {
            elCell.innerHTML = "是";
        } else {
            elCell.innerHTML = "";
        }
    }
    var formatIsSignIn = function (elCell, oRecord, oColumn, sData) {
        if (sData == "0") {
            elCell.innerHTML = "否";
        } else if (sData == "1") {
            elCell.innerHTML = "是";
        } else {
            elCell.innerHTML = "";
        }
    }
    var formatSignIn = function (elCell, oRecord, oColumn, sData) {
        if (sData == "0001-01-01 " || sData == "1900-01-01 ") {
            elCell.innerHTML = "";
        } else {
            elCell.innerHTML = sData;
        }
    }

    //加载业绩归属
    var LoadDeptListData = function () {     
        YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&id=" + Id + "&action=check&entity=MajorStudentDeptName",
            { success: function (res) {
                try {
                    var str = res.responseText;
                    var arr = [];
                    var obj = eval(str);
                    document.getElementById("DeptName").options.length = 0;
                    $("#DeptName").append("<option value=''> </option>");
                    for (var i = 0; i < obj.length; i++) {
                        $("#DeptName").append("<option value='" + obj[i].OrderofDeptName + "'>" + obj[i].OrderofDeptName + "</option>");
                    }
                }
                catch (e) {
                }
                finally {
                }
            }, failure: function () { }
            });
    }
    //加载客户经理
    var LoadCustomerMgrName = function () {
        YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&id=" + Id + "&action=check&entity=MajorStudentCustomerMgrName",
            { success: function (res) {
                try {
                    var str = res.responseText;
                    var arr = [];
                    var obj = eval(str);
                    document.getElementById("CustomerMgrName").options.length = 0;
                    $("#CustomerMgrName").append("<option value=''> </option>");
                    for (var i = 0; i < obj.length; i++) {
                        $("#CustomerMgrName").append("<option value='" + obj[i].CustomerMgrName + "'>" + obj[i].CustomerMgrName + "</option>");
                    }
                }
                catch (e) {
                }
                finally {
                }
            }, failure: function () { }
            });
    }

    //选择客户编码显示客户信息
    var LoadStudentData = function () {
        var vId = " ProductLayoutID='" + Id + "' and Exp5='0' order by GroupName,GroupNumber";
        YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_CrmDeliverMajorStudent&customCondition=" + vId + "",
            { success: function (res) {
                try {
                    var str = res.responseText;
                    var arr = [];
                    var obj = eval(str);
                    SetFormValue(obj);
                    LoadStudentCount("", "", "", "", "", "", "", "");
                }
                catch (e) {
                }
                finally {
                }
            }, failure: function () { }
            });
    }
    //加载数目
    var LoadStudentCount = function (CustomerName, ClassName, GroupName, DeptName, CustomerMgrName, IsDecision, IsTrain, IsSignIn) {
        var json = CustomerName + "$" + ClassName + "$" + GroupName + "$" + DeptName + "$" + CustomerMgrName + "$" + IsDecision + "$" + IsTrain + "$" + IsSignIn;
        var url = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=check&entity=MajorStudentSignCount&id=" + Id + "&json=" + encodeURI(json) + "";
        YAHOO.util.Connect.asyncRequest('GET', url,
            { success: function (res) {
                try {
                    var str = res.responseText;
                    var strs = new Array(); //定义一数组
                    strs = str.split("$"); //字符分割
                    if (strs[0] == "" || strs[0] == "0") {
                        $("#TotalCount").text("0");
                    } else {
                        $("#TotalCount").text(strs[0]);
                    }
                    if (strs[1] == "" || strs[1] == "0") {
                        $("#IsGroupCount").text("0");
                    } else {
                        $("#IsGroupCount").text(strs[1]);
                    }
                    if (strs[2] == "" || strs[2] == "0") {
                        $("#UnGroupCount").text("0");
                    } else {
                        $("#UnGroupCount").text(strs[2]);
                    } //////
                    if (strs[3] == "" || strs[3] == "0") {
                        $("#IsTrainCount").text("0");
                    } else {
                        $("#IsTrainCount").text(strs[3]);
                    }
                    if (strs[4] == "" || strs[4] == "0") {
                        $("#IsSignInCount").text("0");
                    } else {
                        $("#IsSignInCount").text(strs[4]);
                    }
                    if (strs[5] == "" || strs[5] == "0") {
                        $("#IsUnSignInCount").text("0");
                    } else {
                        $("#IsUnSignInCount").text(strs[5]);
                    }
                    if (strs[6] == "" || strs[6] == "0") {
                        $("#IsCustomerNameCount").text("0");
                    } else {
                        $("#IsCustomerNameCount").text(strs[6]);
                    }
                }
                catch (e) {
                }
                finally {
                }
            }, failure: function () { }
            });
    }
    //设置值
    var SetFormValue = function (obj) {
        var arr = eval(obj);
        myDataSource.liveData = arr;
        myDataTable.getDataSource().sendRequest(null, { success: myDataTable.onDataReturnInitializeTable }, myDataTable);
    }
    var IsReresh = 0;
    var SaveValue = function (f, newData, oldData) {
        var recordID = myDataTable.getSelectedRows()[0];
        if (recordID != null && recordID.length != 1) {
            record = myDataTable.getRecord(recordID);
            record._oData[f] = newData;
            var sId = record._oData["MajorStudentId"];
            var sGroupName = record._oData["GroupName"];
            var sGroupNumber = record._oData["GroupNumber"];
            if (f == "GroupName") {
                if (sGroupName == "0") {
                    alert("数值不能0!");
                    record._oData[f] = oldData;
                    record._oData["GroupName"] = oldData;
                } else {
                    IsReresh = 0;
                    UpdateStudentGroupName(sId, sGroupName, sGroupNumber);
                }
            }
            if (f == "GroupNumber") {
                if (sGroupNumber == "0") {
                    alert("数值不能0!");
                    record._oData[f] = oldData;
                    record._oData["GroupNumber"] = oldData;
                } else {
                    IsReresh = 1;
                    UpdateStudentGroupName(sId, sGroupName, sGroupNumber);
                }
            }
        }
        var CustomerName = $("#CustomerName").val();
        var ClassName = $("#ClassName").val();
        var GroupName = $("#GroupName").val();
        var DeptName = $("#DeptName").val();
        var CustomerMgrName = $("#CustomerMgrName").val();
        var IsDecision = $("#IsDecision").val();
        var IsTrain = $("#IsTrain").val();
        var IsSignIn = $("#IsSignIn").val();
        LoadStudentCount(CustomerName, ClassName, GroupName, DeptName, CustomerMgrName, IsDecision, IsTrain, IsSignIn);
    }
    var UpdateStudentGroupName = function (sId, sGroupName, sGroupNumber) {
        var url = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&pid=" + Id + "&id=" + sId + " &name=" + sGroupName + "&number=" + sGroupNumber + " &action=update&entity=CrmStudentSign";
        YAHOO.util.Connect.asyncRequest('GET', url,
            { success: function (res) {
                try {
                    var str = res.responseText;
                    if (str != "1") {
                        alert(str);
                    } else {
                        if (IsReresh == 1) {
                            QueryData();
                        }
                    }
                }
                catch (e) {
                }
                finally {
                }
            }, failure: function () { }
            });
    }
    //设为团长
    var onRowDoubleSetColonel = function () {
        var recordID = myDataTable.getSelectedRows()[0];
        if (recordID != null && recordID.length != 1) {
            record = myDataTable.getRecord(recordID);
            var sId = record._oData["MajorStudentId"];
            var sGroupName = record._oData["GroupName"];
            if (sGroupName == "0" || sGroupName == "") {
                alert("您当前选中学员还未分团,不能设为团长!");
                return;
            } else {
                if (confirm("是否确定将该学员设置为团长?")) {
                    SetColonel(sId);
                }
            }
        }
    }
    var SetColonel = function (studentId) {
        var url = "../../Extend/AjaxData/DataProcessin.aspx?r=" + Math.random() + "flag=1&action=Update&entity=V_CrmMajorStudent&id=" + studentId + "";
        YAHOO.util.Connect.asyncRequest('GET', url,
            { success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        alert("设置成功!");
                        BindData();
                    } else {
                        alert("设为团长失败!");
                    }
                }
                catch (e) {
                }
                finally {
                }
            }, failure: function () { }
            });
    }

    //查询
    var QueryData = function () {
        var CustomerName = $("#CustomerName").val();
        var ClassName = $("#ClassName").val();
        var GroupName = $("#GroupName").val();
        var DeptName = $("#DeptName").val();
        var CustomerMgrName = $("#CustomerMgrName").val();
        var IsDecision = $("#IsDecision").val();
        var IsTrain = $("#IsTrain").val();
        var IsSignIn = $("#IsSignIn").val();
        var json = CustomerName + "$" + ClassName + "$" + GroupName + "$" + DeptName + "$" + CustomerMgrName + "$" + IsDecision + "$" + IsTrain + "$" + IsSignIn;
        var url = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=check&entity=MajorStudentDataList&json=" + encodeURI(json) + "&id=" + Id + "";
        YAHOO.util.Connect.asyncRequest('GET', url,
            { success: function (res) {
                try {
                    var str = res.responseText;
                    var arr = [];
                    var obj = eval(str);
                    SetFormValue(obj);
                    LoadStudentCount(CustomerName, ClassName, GroupName, DeptName, CustomerMgrName, IsDecision, IsTrain, IsSignIn);
                }
                catch (e) {
                }
                finally {
                }
            }, failure: function () { }
            });
    }
    //资源分配
    var ids = [], json = "";
    var fnResource = function () {
        ids = "";
        var list = myDataTable.getRecordSet()._records;
        var elist = [];
        for (var i = 0; i < list.length; i++) {
            if (list[i]._oData["iSun_Selected"] == true) {
                elist.push(list[i]._oData["CustomerId"]);  //按客户分配资源
            }
        }
        ids = elist;
        if (ids.length > 0) {
            var getUrl = "http://" + this.location.host + "/EditWidows/";
            var condition = "";
            var src = getUrl + "ChooseList.aspx?r=" + Math.random() + "&entity=V_UserEmp&kid=UserID&kname=Name&condition=" + decodeURI(condition);
            document.getElementById("EditUIWindow1").src = src;
            YAHOO.example.container.dialog1.show();
        } else {
            alert("您没有勾选任何项!");
        }
    }
    //取消资源分配
    var fnCancelResource = function () {
        ids = "";
        var list = myDataTable.getRecordSet()._records;
        var elist = [];
        for (var i = 0; i < list.length; i++) {
            if (list[i]._oData["iSun_Selected"] == true) {
                elist.push(list[i]._oData["CustomerId"]);  //按客户分配资源
            }
        }
        ids = elist;
        if (ids.length > 0) {
            SaveResource(1);
        } else {
            alert("您没有勾选任何项!");
        }
    }
    var SaveResource = function (obj) {
        json = "";
        if (confirm("是否确定保存?")) {
            for (var i = 0; i < ids.length; i++) {
                json += ids[i] + ",";
            }
            if (obj == "1") {
                uId = "00000000-0000-0000-0000-000000000000,";
            }
            var url = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=update&entity=SetNegotiateTeach&json=" + json + "&id=" + uId + "&pid=" + Id + "";
            YAHOO.util.Connect.asyncRequest('GET', url,
            { success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        alert("分配成功!");
                        QueryData();
                    } else {
                        alert(str);
                    }
                }
                catch (e) {
                }
                finally {
                }
            }, failure: function () { }
            });
        }
    }
</script>
</html>
